package cn.lysj.framework.order.controller;

import cn.lysj.framework.base.BaseController;
import cn.lysj.framework.common.annotation.CurrentUser;
import cn.lysj.framework.common.domain.User;
import cn.lysj.framework.common.utils.pagination.PageVo;
import cn.lysj.framework.common.utils.web.Resp;
import cn.lysj.framework.order.domain.FoodOrder;
import cn.lysj.framework.order.service.FoodOrderService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author zwj
 * @description 订单控制层
 * @create 2018-11-05 09:51:42
 **/
@Slf4j
@RestController
@Api(description = "订单管理接口")
@RequestMapping("/food_order")
public class FoodOrderController extends BaseController<FoodOrder> {

    @Resource
    private FoodOrderService foodOrderService;



    @Override
    public FoodOrderService getService() {
        return foodOrderService;
    }

    @Override
    public Resp list(FoodOrder foodOrder, PageVo pageVo) {
        return null;
    }

    @Override
    public Resp save(FoodOrder foodOrder) {
        return null;
    }


    @GetMapping("/list_rewrite")
    public Resp list(@CurrentUser User user, FoodOrder foodOrder, PageVo pageVo) {
        foodOrder.setStoreId(user.getStoreId());
        return new Resp(foodOrderService.list(foodOrder, pageVo));
    }

    /*
     * @author drj
     * @date 2019-02-19 16:02
     * @Description :处理退款申请
     */
    @PostMapping("/refund_handle")
    public Resp refundHandle(String foodOrderId, Integer foodOrderStatus, BigDecimal money) {
        return foodOrderService.refundHandle(foodOrderId, foodOrderStatus, money);
    }

    /*
     * @author drj
     * @date 2019-02-25 10:47
     * @Description :确认收款
     */
    @PostMapping("/affirm_money_to_order")
    public Resp affirmMoneyToOrder(String foodOrderId) {
        return foodOrderService.affirmMoneyToOrder(foodOrderId);
    }

    /*
     * @author drj
     * @date 2019-02-25 10:47
     * @Description :上菜完成
     */
    @PostMapping("/food_close")
    public Resp foodClose(String foodOrderId) {
        return foodOrderService.foodClose(foodOrderId);
    }



}
